package com.huxin.servelt;

import com.alibaba.fastjson.JSON;
import com.huxin.pojo.UserInfo;
import com.huxin.service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/user/topUser")
public class UserTopUserServlet extends HttpServlet {
    private Userservice userservice=new Userservice();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        List<UserInfo> selectallreader = userservice.selectAllOrderByFrequency();
        String jsonString = JSON.toJSONString(selectallreader);
        resp.getWriter().write(jsonString);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
